<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Yy</title>
</head>

<body>
    <script>
        //if else if
        var a = 10;
        var b = 20;
        var c = "+"
        if (c == "+") {
            console.log(a + b);
        } else if (c == "-") {
            console.log(a - b);
        } else if (c == "*") {
            console.log(a * b);
        } else if (c == "/") {
            console.log(a / b);
        }
        //switch
        // 2.用switch语句输出四则运算的结果
        switch (c) {
            case "+":
                console.log(a + b);
                break;
            case "-":
                console.log(a - b);
                break;
            case "*":
                console.log(a * b);
                break;
            case "/":
                console.log(a / b);
                break;
            default:
                console.log("符号错误");
        }
    </script>
</body>

</html>